// 新闻公告 选项卡
;(function () {
  let newsTitList = document.querySelectorAll('.news-title>h5')
  let newsContList = document.querySelectorAll('.news-right>ul')

  newsTitList.forEach((item, index) => {
    item.index = index
    item.addEventListener('mouseenter', function () {
      newsTab(this.index)
    })
  })
  function newsTab(ind) {
    newsTitList.forEach((item, index) => {
      item.classList.remove('activeTit')
      newsContList[index].classList.remove('activeCont')
    })
    newsTitList[ind].classList.add('activeTit')
    newsContList[ind].classList.add('activeCont')
  }

  // 新闻轮播图
  let newsSwiper = new Swiper('#newsSwiper', {
    autoplay: true,
    pagination: {
      el: '.swiper-pagination',
      clickable: true,
      bulletClass: 'my-bullet', // 非激活状态的class
      bulletActiveClass: 'my-bullet-active' // 激活状态的class
    }
  })

  // 精选游记轮播
  let mesSwiper = new Swiper('#shareSwiper', {
    navigation: {
      nextEl: '.swiper-button-next',
      prevEl: '.swiper-button-prev'
    }
  })
})()

// 手风琴
;(function () {
  const panels = document.querySelectorAll('.panel')
  panels.forEach((panel) => {
    panel.addEventListener('mouseenter', () => {
      removeActiveClasses()
      panel.classList.add('active')
    })
  })

  function removeActiveClasses() {
    panels.forEach((panel) => {
      panel.classList.remove('active')
    })
  }
})()
